up: programming:c:conversions  
c programming
function strtoul
What links here?
Convert string to unsigned long integer

Parses the C string str interpreting its content as an unsigned integral number of the specified base, which is returned as an unsigned long int value.

The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax that depends on the base parameter, and interprets them as a numerical value. Finally, a pointer to the first character following the integer representation in str is stored in the object pointed by endptr.

If the value of base is zero, the syntax expected is similar to that of integer constants, which is formed by a succession of:

If the base value is between 2 and 36, the format expected for the integral number is a succession of the valid digits and/or letters needed to represent integers of the specified radix (starting from '0' and up to 'z'/'Z' for radix 36). If the base is 16, the sequence may optionally be preceded by "0x" or "0X", which is ignored.

If the first sequence of non-whitespace characters in str is not a valid integral number as defined above, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.

= Convert string to unsigned long integer = Parses the C string str interpreting its content as an unsigned integral number of the specified base, which is returned as an unsigned long int value.

The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax that depends on the base parameter, and interprets them as a numerical value. Finally, a pointer to the first character following the integer representation in str is stored in the object pointed by endptr.

If the value of base is zero, the syntax expected is similar to that of integer constants, which is formed by a succession of:

If the base value is between 2 and 36, the format expected for the integral number is a succession of the valid digits and/or letters needed to represent integers of the specified radix (starting from '0' and up to 'z'/'Z' for radix 36). If the base is 16, the sequence may optionally be preceded by "0x" or "0X", which is ignored.

If the first sequence of non-whitespace characters in str is not a valid integral number as defined above, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.

Syntax

unsigned long int strtoul(const char* str, char** endptr, int base)


Parameters



Return Value

On success, the function returns the converted integral number as a long int value.

If no valid conversion could be performed, a zero value is returned.

If the correct value is out of the range of representable values, ULONG_MAX is returned, an the global variable errno is set to ERANGE.
programming - c - functions - strtoul
filename:programming - c - functions - strtoul
filename:programming%20%2D%20c%20%2D%20functions%20%2D%20strtoul
last edit:February 06 2010 08:34:58 (5202 days ago)
ct = 1714950245.000000 = May 05 2024 19:04:05
ft = 1265463298.000000 = February 06 2010 08:34:58
dt = 449486947.000000